#include<bits/stdc++.h>
using namespace std;
int d[100005],v[100005],a[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    while(t--){
        int n,m,ll,vv,ans=0;
        cin>>n>>m>>ll>>vv;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]==0)
                if(vv<v[i])
                    ans++;
        }
        cout<<ans<<" "<<m-1<<endl;
    }
    return 0;
}
